<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
        div{
            border: 1px solid #000;
            width: 200px;
            height: 100px;
            margin: 200px auto;
            background: rgb(129, 171, 181);
            box-shadow: 0px 0px 10px 3px teal ;
        }
    button{
        margin-left: 36px;
        background: rgb(135, 209, 213);
        color: black;
        
        
        
    }

    h1{
        color: white;
        margin-left: 19px;
    }
    
    
    </style>
</head>
<body>
    <div>
            <button id="start">开始</button>
            <button id="end">结束</button>
            <h1 id="txt">开始抽奖吧</h1>
    </div>
    

    <script>
        
        
        var tag=document.getElementById('txt');
        var start=document.getElementById('start');
        var end=document.getElementById('end');
        var timer;

        var list=['电冰箱一台','洗衣机一台','碧桂园一套','三亚七日游','保时捷一辆','再来一次吧','恭喜没中奖','吃达威仙屁'];

        console.log(list[0]);
        console.log(list.length);

   
        

        start.onclick=function(){
            clearInterval(timer);
            

            timer=setInterval(function(){

            

            var n=parseInt(Math.random()*list.length);
            tag.innerHTML=list[n]

            },100)

        }
        

        end.onclick=function(){

            clearInterval(timer);

    }

    
    </script>
    
</body>
</html>